/* 
 * File:   Construct.h
 * Author: brady
 *
 * Created on April 11, 2011, 10:42 AM
 */

#ifndef CONSTRUCT_H
#define	CONSTRUCT_H

#include <math.h>
#include <float.h>
#include <vector>
#include "Shape.h"


class Construct : public Shape {
public:
    static const int UNION = 0;
    static const int DIFFERENCE = 1;
    static const int INTERSECTION = 2;
    Construct();
    Construct(Shape* leftShape, Shape* rightShape, int operation);
    virtual ~Construct();
    void Finalize();
    void SetOperation(int op){Operation = op;}
    void SetLeftShape(Shape* s){LeftShape = s;}
    void SetRightShape(Shape* s){RightShape = s;}
   
    //inhereted from shape
    bool TestIntersect(Ray &ray, double tmin, double tmax, HitStruct& hitStruct);
    double GetSortValue(int sortBy);
    void SetShader(Shader* shader){this->shader = shader;}
    Shader* GetShader(){return this->shader;}



private:
    int Operation;
    Shape* LeftShape;
    Shape* RightShape;
    
};

 static bool isInside(double t, vector<HitStruct>& entries, vector<HitStruct>& exits);

class HitStructComparitor{
public:
    bool operator() (HitStruct h1, HitStruct h2)
    {
       return (h1.tVal < h2.tVal);
    }
};



#endif	/* CONSTRUCT_H */

